<template>
  <div>
    <p class="title">推荐歌单</p>

    <van-row gutter="6">
      <van-col span="8" v-for="obj in reList" :key="obj.id">
        <van-image width="100%" height="3rem" fit="cover" :src="obj.picUrl" />
        <p class="song_name">{{ obj.name }}</p>
      </van-col>
      <!-- <van-col span="8">
        <van-image width="100%" height="3rem" fit="cover" src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" />
        <p class="song_name">歌单名称</p>
      </van-col> -->
    </van-row>

    <p class="title">最新音乐</p>
    <SongItem
      v-for="obj in songList"
      :key="obj.id"
      :name="obj.name"
      :author="obj.song.artists[0].name"
      :id="obj.id"
    >
    </SongItem>
    <!-- <van-cell :title="obj.name" :label="obj.song.artists[0].name" v-for="obj in songList" :key="obj.id">
      <template #right-icon>
        <van-icon name="play-circle-o" class="search-icon" size="0.6rem" />
      </template>
    </van-cell> -->
  </div>
</template>


<script>
import { recommendMusicAPI, newMusicAPI } from "../../api/index";
import SongItem from "../../components/SongItem.vue";
export default {
  name: "home-index",
  components: {
    SongItem,
  },
  data() {
    return {
      reList: [], // 推荐歌单数据
      songList: [], // 最新音乐数据
    };
  },
  async created() {
    try {
      const res = await recommendMusicAPI({
        limit: 9,
      });
      console.log(res);
      this.reList = res.result;

      const res2 = await newMusicAPI({
        limit: 20,
      });
      console.log(res2);
      this.songList = res2.result;
    } catch (error) {
      // 当借口返回错误的信息在catch中处理
      console.log(error);
    }
  },
};
</script>

<style lang="less" scoped>
/* 标题 */
.title {
  padding: 0.266667rem 0.24rem;
  margin: 0 0 0.24rem 0;
  background-color: #bcdd83;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  font-size: 0.346667rem;
  padding: 0 0.08rem;
  margin-bottom: 0.266667rem;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
  background-image: url("../../../public/u=2185853785,3323048027&fm=253&fmt=auto&app=138&f=JPEG.webp");
  background-repeat: no-repeat;
  background-size: cover;
}

.van-cell {
  border-bottom: 1px solid lightgray;
  background-color: #c67c8b;
  /* color: yellow; */
}

/* 穿透样式 */
/deep/ .van-cell__label {
  color: aqua;
}
</style>